def P(int num):

    if (num <= 1)
        return false;
    for (int i = 2; i * i <= num; ++i)
    
        if (num % i == 0)
            return false;
    
    return true;


def f(int num):
    int s = num - 1;
    int l = num + 1;
    while (true):
        if (P(s)):
            return s;
        elif (P(l))
            return l;
        s = s-1;
        l = l + 1;
razryad = 0;
s = str(input())
spaces = 0;
spaces1 = 0;
for i in range(len(s){
    if(s[i] == ' ')
        spaces += 1;
}
chislo = 0;
for i in s:(int i = 0;i < N; i++){
    if(spaces1 == spaces){
        s1 = s.substr(0);
        if(s1 == "one")
            chislo += 1;
        if(s1 == "two")
            chislo += 2;
        if(s1 == "three")
            chislo += 3;
        if(s1 == "four")
            chislo += 4;
        if(s1 == "five")
            chislo += 5;
        if(s1 == "six")
            chislo += 6;
        if(s1 == "seven")
            chislo += 7;
        if(s1 == "eight")
            chislo += 8;
        if(s1 == "nine")
            chislo += 9;
        break;       
    }
    if(s[i] == ' '){
        razryad++;
        spaces1 += 1;
        s1 = s.substr(0,i);
        s = s.erase(0,i+1);
        i = 0;
        if(razryad == 1){
            if(s1 == "one")
                chislo += 100;
            if(s1 == "two")
                chislo += 200;
            if(s1 == "three")
                chislo += 300;
            if(s1 == "four")
                chislo += 400;
            if(s1 == "five")
                chislo += 500;
            if(s1 == "six")
                chislo += 600;
            if(s1 == "seven")
                chislo += 700;
            if(s1 == "eight")
                chislo += 800;
            if(s1 == "nine")
                chislo += 900;
            }
        }
        if(razryad == 2){
            if(s1 == "one")
                chislo += 10;
            if(s1 == "two")
                chislo += 20;
            if(s1 == "three")
                chislo += 30;
            if(s1 == "four")
                chislo += 40;
            if(s1 == "five")
                chislo += 50;
            if(s1 == "six")
                chislo += 60;
            if(s1 == "seven")
                chislo += 70;
            if(s1 == "eight")
                chislo += 80;
            if(s1 == "nine")
                chislo += 90;
        }
    }
}
int result = f(chislo);
cout << result;
